package com.css.zfzx.data.primary.yhDisasterPG.repository;

import com.css.zfzx.data.primary.yhDisasterPG.repository.entity.YhDisasterPGEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: data
 * @Author: lhl
 * @CreateDate: 2021/4/21 10:34
 */
@Repository
public interface YhDisasterPGRepository extends JpaRepository<YhDisasterPGEntity,String> {
    @Query(value = "select * from yh_disaster  where create_time like :format and is_valid = 1  and update_time is null" +
            "and yh_project_type in ('老旧居民小区','学校','医院', '商业中心', '养老福利院')",nativeQuery = true)
    List<YhDisasterPGEntity> findFwAllByCreateTime(@Param("format") String format);

    @Query(value = "select * from yh_disaster  where is_valid = 1  and update_time like :format" +
            "and yh_project_type in ('老旧居民小区','学校','医院', '商业中心', '养老福利院')",nativeQuery = true)
    List<YhDisasterPGEntity> findFwAllByUpdateTime(@Param("format") String format);

    @Query(value = "select * from yh_disaster  where is_valid = 1 " +
            "and yh_project_type in ('老旧居民小区','学校','医院', '商业中心', '养老福利院')",nativeQuery = true)
    List<YhDisasterPGEntity> findFwAll();

    @Query(value = "select * from yh_disaster  where is_valid = 1",nativeQuery = true)
    List<YhDisasterPGEntity> findAll();

}
